﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Quanly
{
    public partial class Frm_Main : DevExpress.XtraEditors.XtraForm
    {
        Frm_Abstract frmchild;
        public Frm_Main()
        {   
            InitializeComponent();
        }

        private void mnu_SanPham_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            close();
            frmchild = new Frm_QuanLiSanPham();
            frmchild.MdiParent = this;
            frmchild.Show();           
        }

        private void mnu_PhieuDatHang_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            close();
            frmchild = new Frm_XuLyDonDatHang();
            frmchild.MdiParent = this;
            frmchild.Show();
        }

        public bool checkFrmChild()
        {
            if (this.ActiveMdiChild == null)
            {
                return false;
            }
            return true;
        }

        public void close()
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void bnt_luu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (checkFrmChild())
            {
                this.frmchild = (Frm_Abstract)this.ActiveMdiChild;
                this.frmchild.update();
            }
        }

        private void bnt_Them_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (checkFrmChild())
            {
                this.frmchild = (Frm_Abstract)this.ActiveMdiChild;
                this.frmchild.save();
            }
        }

        private void bnt_Xoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (checkFrmChild())
            {
                this.frmchild = (Frm_Abstract)this.ActiveMdiChild;
                this.frmchild.delete();
            }
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (checkFrmChild())
            {
                this.frmchild = (Frm_Abstract)this.ActiveMdiChild;
                this.frmchild.refresh();
            }
        }

        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (checkFrmChild())
            {
                this.frmchild = (Frm_Abstract)this.ActiveMdiChild;
                this.frmchild.closeForm();
            }
        }

        private void bnt_Thoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void mnu_QLDanhMuc_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            close();
            frmchild = new Frm_QuanLyDanhMuc();
            frmchild.MdiParent = this;
            frmchild.Show();
        }






    }
}